home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 09 - 1993 / 09.06 Jun 93 / C Shell XCMD / BEditPane.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-01  |  2.4 KB  |  106 lines  |  [TEXT/KAHL]

  1. /******************************************************************************
  2.     BEditPane.c
  3.     
  4.     Methods for a text editing pane.
  5.         
  6.     Copyright © 1989 Symantec Corporation. All rights reserved.
  7.  
  8.  ******************************************************************************/
  9.  
  10.  
  11. #include "BEditPane.h"
  12. #include <Commands.h>
  13. #include <CDocument.h>
  14. #include <CBartender.h>
  15. #include <Constants.h>
  16.  
  17. extern    CBartender    *gBartender;
  18.  
  19. void BEditPane::IEditPane(CView *anEnclosure, CBureaucrat *aSupervisor)
  20.  
  21. {
  22.     Rect    margin;
  23.  
  24.     CEditText::IEditText(anEnclosure, aSupervisor, 1, 1, 0, 0,
  25.                         sizELASTIC, sizELASTIC, 600);   // change 432 to 600
  26.     FitToEnclosure(TRUE, TRUE);
  27.  
  28.         /**
  29.          **    Give the edit pane a little margin.
  30.          **    Each element of the margin rectangle
  31.          **    specifies by how much to change that
  32.          **    edge. Positive values are down and to
  33.          **    right, negative values are up and to
  34.          **    the left.
  35.          **
  36.          **/
  37.  
  38.     SetRect(&margin, 2, 2, -2, -2);
  39.     ChangeSize(&margin, FALSE);
  40. }
  41.  
  42. void BEditPane::DoCommand(long theCommand)
  43.  
  44. {
  45.     
  46.     if (((theCommand == cmdPaste) || (theCommand == cmdCut)) && 
  47.         !((CDocument *)itsSupervisor)->dirty) {
  48.         
  49.         ((CDocument *)itsSupervisor)->dirty = TRUE;
  50.         gBartender->EnableCmd(cmdSave);
  51.         gBartender->EnableCmd(cmdSaveAs);
  52.     }
  53.  
  54.     inherited::DoCommand(theCommand);
  55. }
  56.  
  57.  
  58. void BEditPane::DoKeyDown(char theChar, Byte keyCode, EventRecord *macEvent)
  59.  
  60. {
  61.     
  62.     inherited::DoKeyDown(theChar, keyCode, macEvent);
  63.  
  64.     switch (keyCode) {
  65.     
  66.         case KeyHome:
  67.         case KeyEnd:
  68.         case KeyPageUp:
  69.         case KeyPageDown:
  70.             break;
  71.             
  72.         default:    
  73.             if (!((CDocument *)itsSupervisor)->dirty) {
  74.                 ((CDocument *)itsSupervisor)->dirty = TRUE;
  75.                 gBartender->EnableCmd(cmdSave);
  76.                 gBartender->EnableCmd(cmdSaveAs);
  77.             }
  78.             break;
  79.     }
  80. }
  81.  
  82.  
  83. void BEditPane::DoAutoKey(char theChar, Byte keyCode, EventRecord *macEvent)
  84.  
  85. {
  86.     
  87.     inherited::DoAutoKey(theChar, keyCode, macEvent);
  88.  
  89.     switch (keyCode) {
  90.     
  91.         case KeyHome:
  92.         case KeyEnd:
  93.         case KeyPageUp:
  94.         case KeyPageDown:
  95.             break;
  96.             
  97.         default:    
  98.             if (!((CDocument *)itsSupervisor)->dirty) {
  99.                 ((CDocument *)itsSupervisor)->dirty = TRUE;
  100.                 gBartender->EnableCmd(cmdSave);
  101.                 gBartender->EnableCmd(cmdSaveAs);
  102.             }
  103.             break;
  104.     }
  105. }
  106.